package mysql

import "gorm.io/gorm"

type Purchaser struct {
	gorm.Model
	Name   string `gorm:"type:varchar(50);not null;comment:姓名"`
	IdCary string `gorm:"type:varchar(18);not null;comment:身份证"`
}

func (s *Purchaser) ShowPurchaser(id int64) (result *Purchaser, err error) {
	err = DB.Model(&Purchaser{}).Where("id=?", id).Limit(1).Find(&result).Error
	return
}

func (s *Purchaser) CreatePurchaser() error {
	return DB.Create(s).Error
}

func (s *Purchaser) List() (result []*Purchaser, err error) {
	err = DB.Model(&Purchaser{}).Find(&result).Error
	return
}
